import { Controller, Get } from "@nestjs/common";
import { IsNotEmpty } from "class-validator";
import {
  HealthCheck,
  HealthCheckService,
  TypeOrmHealthIndicator,
} from "@nestjs/terminus";

export class TestValidation {
  @IsNotEmpty()
  name: string;
}

@Controller("health")
export class HealthController {
  constructor(
    private readonly healthCheckService: HealthCheckService,
    private readonly typeormHealthIndicator: TypeOrmHealthIndicator
  ) {}

  @Get()
  @HealthCheck()
  check() {
    return this.healthCheckService.check([
      () => this.typeormHealthIndicator.pingCheck("database"),
    ]);
  }
}
